
import { defineStore } from "pinia";
export const useMeasureData=defineStore('measureData',{
    state:()=>{
        return {
            measureData:[]
        }
    },
    getters:{
        // 获取全部信息
        allData(){
            return this.measureData
        }
    },
    actions:{
        setData(data){
            return new Promise((resolve,reject)=>{
                this.measureData=data.length?data:[]
                resolve(data)
            })
        },
        clearData(){
          return new Promise((resolve,reject)=>{
            const data=this.measureData.map(item=>{
              item.length && item.forEach(n=>n.measures.length=0)
              return item
            })
            this.measureData=data
            resolve(data)
          })
        }
    },
  })